package net.lshimokawa.corespring.nbdemo.controller;

import java.io.IOException;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import net.lshimokawa.corespring.nbdemo.model.Cliente;
import net.lshimokawa.corespring.nbdemo.service.ClienteService;
import net.lshimokawa.corespring.nbdemo.service.ClienteServiceImpl;

/**
 *
 * @author Lennon Shimokawa
 */
public class ClienteController extends HttpServlet {

    private ClienteService clienteService;

    public ClienteController() {
        this.clienteService = new ClienteServiceImpl();
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        List<Cliente> clientes = clienteService.getClientes();
        req.setAttribute("clientes", clientes);
        getServletContext().getRequestDispatcher("/WEB-INF/jsp/clientes.jsp").forward(req, resp);
        
    }
}
